//
//  EssentialTableViewCell.m
//  Menu
//
//  Created by dllo on 15/7/8.
//  Copyright (c) 2015年 lijiangang. All rights reserved.
//

#import "EssentialTableViewCell.h"

@implementation EssentialTableViewCell

- (void)dealloc
{
    [_essentialImgView release];
    [_essentialLabel release];
    [_directionImgView release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.essentialImgView = [[UIImageView alloc] initWithFrame:CGRectMake(5*WIDTH, 5*HEIGHT, 40*WIDTH, 40*HEIGHT)];
    self.essentialImgView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.essentialImgView];
    [_essentialImgView release];
    
    self.essentialLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.essentialImgView.frame.origin.x + self.essentialImgView.frame.size.width + 20*WIDTH, 10*HEIGHT, 100*WIDTH, 30*HEIGHT)];
    self.essentialLabel.backgroundColor = [UIColor whiteColor];
    self.essentialLabel.font = [UIFont systemFontOfSize:17*WIDTH];
    [self.contentView addSubview:self.essentialLabel];
    [_essentialLabel release];
    
    self.directionImgView = [[UIImageView alloc] initWithFrame:CGRectMake(MyWidth - 30*WIDTH, self.essentialLabel.frame.origin.y, 30*WIDTH, 30*HEIGHT)];
    self.directionImgView.image = [UIImage imageNamed:@"direct.png"];
    [self.contentView addSubview:self.directionImgView];
    [_directionImgView release];
}

-(void)setEssentialModel:(EssentialModel *)essentialModel
{
    if (_essentialModel != essentialModel)
    {
        [_essentialModel release];
        _essentialModel = [essentialModel retain];
    }
    self.essentialLabel.text = essentialModel.title;
    [self.essentialLabel sizeToFit];
    
    [self.essentialImgView sd_setImageWithURL:[NSURL URLWithString:essentialModel.image]];
}


























- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
